<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加住院病人</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script src="../../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
            <td valign="bottom" class="title">添加住院病人</td>
          </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="">
<table width="95%"  border="0" cellpadding="0" cellspacing="0" name="update">


<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">病人姓名</td>-->
<!--    <td colspan="3" class="td_form02">xie</td>-->
<!--  </tr>-->

<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">性别</td>-->
<!--    <td colspan="3" class="td_form02">-->
<!--    nan-->
<!--    </td>-->
<!--  </tr>-->

<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">身份证号</td>-->
<!--    <td colspan="3" class="td_form02">1105641</td>-->
<!--  </tr>-->

<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">联系电话</td>-->
<!--    <td colspan="3" class="td_form02"><input name="textfield" type="text" class="input"></td>-->
<!--  </tr>-->

<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">科室</td>-->
<!--    <td colspan="3" class="td_form02"> <select name="depid">-->

<!--    </select></td>-->
<!--  </tr>-->
<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">主治医生</td>-->
<!--    <td colspan="3" class="td_form02"> <select name="staid1">-->

<!--    </select></td>-->
<!--  </tr>-->
<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">病房</td>-->
<!--    <td colspan="3" class="td_form02"> <select name="sckid">-->

<!--    </select></td>-->
<!--  </tr>-->
<!--  <tr>-->
<!--    <td width="90" align="center" class="td_form01">押金</td>-->
<!--    <td colspan="3" class="td_form02"><input name="inpdeposit" type="text" class="input"></td>-->
<!--  </tr>-->

</table>
  <br>
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center"><input name="Submit" type="submit" class="buttonface" value="  增加  ">
        <input name="Submit" type="submit" class="buttonface" onClick="window.close()" value="  关闭  "></td>
    </tr>
  </table>
  </form>
</center>

<script>

  function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
      var str = url.substr(1);
      strs = str.split("?");
      console.log(strs)
      for (var i = 0; i < strs.length; i++) {
        theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
      }
    }
    return theRequest;
  }
  $(document).ready(function(){
    var a=GetRequest();
    var token = a['token'];
    var inpatientmessage = a['inpatientmessage'];
    Detail(token,inpatientmessage);



  function f1() {



    $("table[name='update']").append("  <tr>\n" +
            "    <td width=\"90\" align=\"center\" class=\"td_form01\">病人姓名</td>\n" +
            "    <td colspan=\"3\" class=\"td_form02\">"+data.pname+"</td>\n" +
            "  </tr>\n" +
            "\n" +

            "  <tr>\n" +
            "    <td width=\"90\" align=\"center\" class=\"td_form01\">联系电话</td>\n" +
            "    <td colspan=\"3\" class=\"td_form02\"><input name=\"textfield\" value='"+data.inpcontact+"' type=\"text\" class=\"input\"></td>\n" +
            "  </tr>\n" +
            "\n" +
            "  <tr>\n" +
            "    <td width=\"90\" align=\"center\" class=\"td_form01\">科室</td>\n" +
            "    <td colspan=\"3\" class=\"td_form02\"> <select name=\"depid\">\n" +
            "\n" +
            "    </select></td>\n" +
            "  </tr>\n" +
            "  <tr>\n" +
            "    <td width=\"90\" align=\"center\" class=\"td_form01\">主治医生</td>\n" +
            "    <td colspan=\"3\" class=\"td_form02\"> <select name=\"staid\">\n" +
            "\n" +
            "    </select></td>\n" +
            "  </tr>\n" +
            "  <tr>\n" +
            "    <td width=\"90\" align=\"center\" class=\"td_form01\">病房</td>\n" +
            "    <td colspan=\"3\" class=\"td_form02\"> <select name=\"sckid\">\n" +
            "\n" +
            "    </select></td>\n" +
            "  </tr>\n" +
            "  <tr>\n" +
            "    <td width=\"90\" align=\"center\" class=\"td_form01\">押金</td>\n" +
            "    <td colspan=\"3\" class=\"td_form02\"><input name=\"inpdeposit\" type=\"text\" class=\"input\"></td>\n" +
            "  </tr>")
    fun1();
  }


  function fun1() {
    $("select[name='depid']").change(function () {
      var depid = $("select[name='depid']").val();
      $.ajax({
        url: "/feign/book/displayStaffByDepartment",
        type: "get",
        dataType: "json",
        data: {"depid": depid,
          "posid":1,
        },
        headers: {
          Accept: "application/json; charset=utf-8",
          Authorization: token
        },
        success: function (index, data) {
          $("select[name='satid']").append("<option value='" + data.staffid + "'>" + data.staname + "</option>")
        }
      })
      $.ajax({
        url: "/feign/book/displayFullSckbed",
        type: "get",
        dataType: "json",
        data: {"depid": depid,

        },
        success: function (index, data) {
          $("select[name='satid2']").append("<option value='" + data.sckid + "'>" + data.sckbedsid + "</option>")
        }
      })
    })

    $("input[id='submit']").on("click",function () {
      $.ajax({
        url:"/feign/book/updateNewMessage",
        type:"post",
        data:$("form").serialize(),
        dataType:"json",
        success:function (data) {
          alert(data.msg)
          if (data.code==200){
            alert(data.msg);
          }
        }
      })
    })
  }
  })

</script>
</body>
</html>
